<template>
	<view>
		<!-- <cu-custom :bgColor="'bg-' + theme.themeColor" :isBack="false">
			<block slot="content">个人中心</block>
		</cu-custom> -->
		<view class="mine-userinfo" style="background-color: #fff;">
			<!-- <view class="mine-userinfo-bg1">
			</view>
			<view class="mine-userinfo-bg2">
			</view>
			<view class="mine-userinfo-bg3">
			</view>
			<view class="mine-userinfo-bg4">
			</view> -->
			<view class="hx-user-info" @tap="goUserDetail" style="padding: 40px 30px;">
				<view class="flex" style="align-items: center">
					<view class="cu-avatar round xl head flex" v-if="userInfo.avatarUrl"
						:style="'background-image:url(' + userInfo.avatarUrl + ')'">
					</view>
					<view class="cu-avatar round xl head flex"  v-else
						:style="'background-image:url(' + defaultPic + ')'">
					</view>
					<view class="nick-name">
						<view v-if="userInfo.id" style="color:#000">
							{{userInfo.nickName || "用户名"}}
						</view>
						<view v-else @tap.stop="goLogin">
							去登录
						</view>
					</view>
				</view>
				<view class="text-xxl">
					<text class="cuIcon-settings text-white" style="position: relative;z-index: 999999; color: #666;"></text>
				</view>
			</view>
			<!-- <view class="grid no-border col-4 padding-xs user-con" style="justify-content: space-around;">
				<view>
					<navigator class="content" hover-class="none" url="/pages/coupon/coupon-user/index?status=0">
						<view class="text-xl">
							<text class="cuIcon-ticket text-white"></text>
						</view>
						<view class="text-white textMar">优惠券<text class="padding-lr-xs">{{userInfo.couponCount || 0}}</text>
						</view>
					</navigator>
				</view>
				<view>
					<navigator class="content" hover-class="none" url="/pages/user/user-footprint/index">
						<view class="text-xl">
							<text class="cuIcon-footprint text-white"></text>
						</view>
						<view class="text-white textMar">足迹</view>
					</navigator>
				</view>
				<view>
					<navigator class="content" hover-class="none" url="/pages/user/user-collect/index">
						<view class="text-xl">
							<text class="cuIcon-favor text-white"></text>
						</view>
						<view class="text-white textMar">收藏</view>
					</navigator>
				</view>
				<view>
					<navigator class="content" hover-class="none" url="/pages/user/user-account/index">
						<view class="text-xl">
							<text class="cuIcon-send text-white"></text>
						</view>
						<view class="text-white textMar">余额 <text
								class="text-price padding-lr-xs">{{userInfo.accountBalance || 0}}</text></view>
					</navigator>
				</view>
			</view> -->
		</view>
		<view class="title-con margin-sm" style="margin-bottom: 0;font-size: 13px;letter-spacing: 1px">
			更多权益等您开启
		</view>
		<view class="margin-sm bg-white" style="margin-top: 0;">
			<view class="flex justify-between padding-lr padding-top-xs mar">
				<view class="text-black text-bold">我的订单</view>
				<navigator class="action " url="/subpkg/order/order-list/index" hover-class="none">
					<text class="text-grey text-sm" style="color: #B6B6B6;font-size: 23.44rpx;">查看全部 <text class="cuIcon-right" style="font-size: 13.5px;"></text></text>
				</navigator>
			</view>
			<view class="cu-list grid no-border col-5" style="width: 93%;margin: 0 auto;padding: 10px 0;">
				<!-- <view class="cu-item" style="width: 25%;padding-right: 10px;" v-for="item in orderList" :key="item.id">
					<navigator class="content" hover-class="none" :url="item.href">
						<view class="cuIcon-pay"  style="margin-top: 0;">
							<image :src="item.imgUrl" mode="" style="width: 57.42rpx;height: 57.42rpx;"></image>
							<view class="cu-tag badge order-tag" v-if="orderCount && orderCount[1]!=0">
								<block>{{orderCount[1]>99?'99+':orderCount[1]}}</block>
							</view>
						</view>
						<view class="text-df colorBlack">{{item.name}}</view>
					</navigator>
				</view> -->
			   <view class="cu-item" style="width: 25%;padding-right: 10px;" >
					<navigator class="content" hover-class="none" :url="orderList[0].href">
						<view class=""  style="margin-top: 0;position: relative;">
							<image :src="orderList[0].imgUrl" mode="" style="width: 75rpx;height: 73.83rpx;"></image>
							<view class="cu-tag badge order-tag" v-if="orderCount && orderCount[1]!=0">
								<block>{{orderCount[1]>99?'99+':orderCount[1]}}</block>
							</view>
						</view>
						<view class="text-df text-black">{{orderList[0].name}}</view>
					</navigator>
			   </view>
			   <view class="cu-item" style="width: 25%;padding-right: 10px;" >
					<navigator class="content" hover-class="none" :url="orderList[1].href">
						<view class=""  style="margin-top: 0;position: relative;">
							<image :src="orderList[1].imgUrl" mode="" style="width: 75rpx;height: 73.83rpx;"></image>
							<view class="cu-tag badge order-tag" v-if="orderCount && orderCount[2]!=0">
								<block>{{orderCount[2]>99?'99+':orderCount[2]}}</block>
							</view>
						</view>
						<view class="text-df text-black">{{orderList[1].name}}</view>
					</navigator>
			   </view>
			   <view class="cu-item" style="width: 25%;padding-right: 10px;" >
					<navigator class="content" hover-class="none" :url="orderList[2].href">
						<view class=""  style="margin-top: 0;position: relative;">
							<image :src="orderList[2].imgUrl" mode="" style="width: 75rpx;height: 73.83rpx;"></image>
							<view class="cu-tag badge order-tag" v-if="orderCount && orderCount[4]!=0">
								<block>{{orderCount[4]>99?'99+':orderCount[4]}}</block>
							</view>
						</view>
						<view class="text-df text-black">{{orderList[2].name}}</view>
					</navigator>
			   </view>
			   <view class="cu-item" style="width: 25%;padding-right: 10px;" >
					<navigator class="content" hover-class="none" :url="orderList[3].href">
						<view class=""  style="margin-top: 0;position: relative;">
							<image :src="orderList[3].imgUrl" mode="" style="width: 75rpx;height: 73.83rpx;"></image>
							<view class="cu-tag badge order-tag" v-if="orderCount && orderCount[5]!=0">
								<block>{{orderCount[5]>99?'99+':orderCount[5]}}</block>
							</view>
						</view>
						<view class="text-df text-black">{{orderList[3].name}}</view>
					</navigator>
			   </view>
			   
			</view>
		</view>
		
		<!-- 广告位 -->
		<view class="advertisement-con margin-sm">
			  <image class="imgStyle" :src="itemBg1" mode=""></image>
			  <image class="imgStyle" :src="itemBg2" mode=""></image>
		</view>


		<view class="margin-sm bg-white" style="border-radius: 0rpx 0rpx 18rpx 18rpx">
			<view class="flex justify-between padding-lr padding-top-xs mar">
				<view class="text-black text-bold">必备工具</view>
			</view>
			<view class="cu-list grid no-border col-5" style="width: 93%;margin: 0 auto;padding: 10px 0;">
				<view class="cu-item" style="width: 25%;padding-right: 10px;" v-for="item in toolList" :key="item.id">
					<navigator class="content" hover-class="none" :url="item.href">
						<view class=""  style="margin-top: 0;position: relative;">
							<image :src="item.imgUrl" mode="" :style="item.style"></image>
						</view>
						<view class="text-df colorBlack" style="color: #000;">{{item.name}}</view>
					</navigator>
				</view>
				
			</view>
			<!-- <view class="cu-list grid no-border col-4" style="flex-direction: column;">
				<view class="cu-item" style="width: 100%;">
					<navigator hover-class="none" url="/pages/user/user-address/index" style="display: flex;align-items: center;justify-content: space-between;">
						<view class="lestStyle">
							<view class="cuIcon-location" style="width: 30px;margin-top: 0;"></view>
							<view class="text-grey" style="color: #000000;">推广码</view>
						</view>
						<view class="rigthStyle">
							<uni-icons type="right" size="25" color="#B6B6B6"></uni-icons>
						</view>
					</navigator>
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	import packageJson from '@/package.json'
	import {
		getCount
	} from '@/api/orderinfo.js';
import badgeMix  from '@/mixins/tabbar-badge.js'
import config from 'config/env'
 export default {
	mixins: [badgeMix],
		data() {
			return {
				theme: getApp().globalData.theme,
				itemBg1:`${config.imgSrcL}ttyfl-one.png`,
				itemBg2:`${config.imgSrcL}ttyfl-three.png`,
				userInfo: {},
				orderCount: null,
				canIUseGetUserProfile: false,
				versionNumber: packageJson.version,
				// 默认的空图片
				defaultPic: 'https://img3.doubanio.com/f/movie/8dd0c794499fe925ae2ae89ee30cd225750457b4/pics/movie/celebrity-default-medium.png',
				orderList:[
					{
						id : 0,
						name : '待付款',
						imgUrl:`${config.imgSrcL}dfks.png`,
						href:'/subpkg/order/order-list/index?status=1'
					},
					{
						id : 1,
						name : '待服务',
						imgUrl:`${config.imgSrcL}kfus.png`,
						href:'/subpkg/order/order-list/index?status=2'
					},
					{
						id : 2,
						name : '待评价',
						imgUrl:`${config.imgSrcL}dpjs.png`,
						href:'/subpkg/order/order-list/index?status=3'
					},
					{
						id : 3,
						name : '退款/售后',
						imgUrl:`${config.imgSrcL}sshous.png`,
						href:'/pages/order/order-refund/refund-list/index'
					}
				],
				toolList:[
					{
						id : 0,
						name : '推广码',
						imgUrl:`${config.imgSrcL}tuigm.png`,
						style:'width: 32.81rpx;height: 32.81rpx;',
						href:'/pages/distribution/distribution-card/index'
					},
					{
						id : 1,
						name : '我的设备',
						imgUrl:`${config.imgSrcL}wdsb.png`,
						style:'width: 32.81rpx;height: 32.81rpx;',
						href:''
					},
					{
						id : 2,
						name : '我的分销',
						imgUrl:`${config.imgSrcL}money.png`,
						style:'width: 32.81rpx;height: 32.81rpx;',
						href:'/pages/distribution/distribution-center/index'
					},
					{
						id : 3,
						name : '技能认证',
						imgUrl:`${config.imgSrcL}dpai.png`,
						style:'width: 32.81rpx;height: 32.81rpx;',
						href:'/subpkg/skill/skillStatus/skillStatus'
					},
					{
						id : 4,
						name : '我的卡包',
						imgUrl:`${config.imgSrcL}kabao.png`,
						style:'width: 33.98rpx;height: 33.98rpx;',
						href:'/pages/user/user-account/index'
					}
				]
			}
		},
		onShow() {
			this.getUserInfo();
			this.getOrderCount();
		},
		onLoad() {
			getApp().initPage({
					isTabar: true
				}).then(res => {})
			if (wx.getUserProfile) {
				this.canIUseGetUserProfile = true
			}
		},
		methods: {
			// 获取用户信息
			getUserInfo() {
				let that = this;
				this.$store.dispatch("GetInfo").then((res) => {
					that.userInfo = res
				}).catch(() => {})
			},
			// 获取订单数量
			getOrderCount() {
				getCount().then(res => {
					this.orderCount = res.data;
				})
			},
			// 跳转登录
			goLogin() {
				uni.navigateTo({
					url: '/pages/login/index'
				});
			},
			// 跳转用户信息
			goUserDetail() {
				uni.navigateTo({
					url: '/pages/setup/setup'
				});
			},
		}
	}
</script>

<style lang="scss">
	.imgStyle{
		width: 345rpx;
		height: 127.73rpx;
		border-radius: 12rpx;
	}
	.advertisement-con{
		display: flex;
		justify-content: space-between;
	}
	.lestStyle{
		flex-direction: row;
		display: flex;
		align-items: center;
	}
	.title-con{
		text-align: center;
		background: linear-gradient(153deg, #252B45, #494F67);
		border-radius: 18rpx 18rpx 0rpx 0rpx;
		height: 40px;
		display: block;
		overflow: hidden;
		color:#F2D7AA;
		line-height: 40px;
	}
	.textMar{
		margin-top: 10rpx;
	}
	.mar{
		padding-top: 11px;
	}
	.user-con{
		padding-bottom: 15px;
	}
	.hx-user-info {
		display: flex;
		padding: 60rpx;
		align-items: center;
		justify-content: space-between;

		.nick-name {
			padding: 20rpx;
		}
	}

	.swiper {
		height: 720rpx;
	}

	.grid-text {
		font-size: 14px;
		color: #909399;
		padding: 10rpx 0 20rpx 0rpx;
		/* #ifndef APP-PLUS */
		box-sizing: border-box;
		/* #endif */
	}

	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 26rpx;
		font-weight: 700;
	}

	.title-right {
		font-size: 24rpx;
		color: #999999;
	}

	.order-bottom {
		display: flex;
		background-color: #F1F1F1;
		border: #F1F1F1 1px solid;
		border-radius: 16rpx;
		margin: 20rpx;

		.right {
			padding-left: 20rpx;

			.title {
				margin-top: 10rpx;
				font-size: 24rpx;
			}

			.describe {
				font-size: 24rpx;
				margin-top: 20rpx;
			}
		}

	}

	.hx-top {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100rpx;

		.item {
			padding: 0rpx 50rpx;
			display: flex;
			align-items: center;

			.name {
				font-weight: 700;
				font-size: 30rpx;
			}
		}
	}

	.mine-userinfo {
		position: relative;
		width: 750rpx;
		z-index: 0;

		&-bg1 {
			position: absolute;
			bottom: 250rpx;
			left: -40rpx;
			width: 300rpx;
			height: 300rpx;
			border-radius: 50%;
			background-color: rgba($color: #fff, $alpha: 0.2);
		}

		&-bg2 {
			position: absolute;
			bottom: 200rpx;
			right: 80rpx;
			width: 100rpx;
			height: 100rpx;
			border-radius: 50%;
			background-color: rgba($color: #fff, $alpha: 0.2);
		}

		&-bg3 {
			position: absolute;
			bottom: 150rpx;
			right: 220rpx;
			width: 40rpx;
			height: 40rpx;
			border-radius: 50%;
			background-color: rgba($color: #fff, $alpha: 0.2);
		}

		&-bg4 {
			position: absolute;
			bottom: 100rpx;
			right: 180rpx;
			width: 20rpx;
			height: 20rpx;
			border-radius: 50%;
			background-color: rgba($color: #fff, $alpha: 0.2);
		}
	}

	.order-tag {
		margin-left: 10rpx !important;
	}
	.colorBlack{
		color: #000 !important;
		margin-top: 5px;
	}
</style>
